package com.company.lifecycleCallbacks.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;

/**
 * @Author: zhaopeng
 * @Date: Created in 11:37 2020/9/29
 * @Modified By:
 */
@Component
public class PreDestroyTest implements ApplicationContextAware {

	private ApplicationContext applicationContext;

	@PreDestroy
	public void clearStudentCache() {
		System.out.println("student是否存在=======> + " +applicationContext.containsBean("student"));
		System.out.println("preDestroy");
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}
}
